<template>
  <div id="app">
    <h1>根组件--{{$store.state.user.userInfo.name}}</h1>
    <p>网站的标题:{{$store.state.setting.title}}</p>


<!-- 调用空间命名下的mutations方法
    1.直接调用
    this.$store.commit('模块名,函数名')
    2.辅助函数(不太推荐)
    ...mapMutations('模块名',['函数名]) -->

    <!-- 同理actions一样
    1.直接调用
    this.$store.dispatch('模块名/函数名')
    2.辅助函数(不推荐)
    ...mapAction('模块名),['函数名] -->
    <button @click="$store.commit('user/test')">调用user的test</button>
    <button @click="$store.commit('setting/test')">setting</button>
    <button @click="test">强调辅助函数导入的test</button>
    <button @click="test">强调辅助函数导入的setting</button>
  
    <input type="text">
    <add-item></add-item>
    <hr>
    <sub-item></sub-item>
  </div>
</template>

<script>
import { mapMutations } from 'vuex'
import AddItem from './components/add-item.vue'
import SubItem from './components/sub-item.vue'

export default {
  name: 'app',
  data: function () {
    return {
      
    }
  },
  methods:{
    ...mapMutations('user',['test']),
    ...mapMutations('setting',['test'])

  },
  components: {
    AddItem,
    SubItem
  }
}
</script>

<style>
#app {
  width: 600px;
  margin: 20px auto;
  border: 3px solid #ccc;
  border-radius: 3px;
  padding: 10px;
}
</style>